<template>
  <a-select v-model='data' show-search style="width: 100%" :filter-option="filterOption" placeholder="请选择" @change='dataChange' allowClear>
    <a-select-option v-for="item in dataList" :key="item.id">
      {{ item.schoolName }}
    </a-select-option>
  </a-select>
</template>

<script>
import { jwhSchoolList } from '@/api/user'
export default {
  name: 'SelectMemberGrage',
  props: {
    value:{
      type: String,
      default: undefined
    },
  },
  data() {
    return {
      data: this.value,
      dataList: []
    }
  },
  created() {
    this.getDateList()
  },
  watch: {
    value(newVal) {
      this.data = newVal
    }
  },
  methods: {
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },
    dataChange(e) {
      this.$emit('input', e)
    },
    getDateList() {
      jwhSchoolList({
        pageNo: 1,
        pageSize: 1000
      }).then((res) => {
        this.dataList = res.result.records
        this.data = this.value
      })
    }
  }
}
</script>

<style scoped>

</style>